package ydn.edu.hqu.cst.myexperiment2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class UC1 extends AppCompatActivity {
    Button UC1_1;
    Button UC1_2;
    Button UC1_3;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_uc1);

        // 水平方向
        UC1_1=findViewById(R.id.button1);
        UC1_1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                LinearLayout l = findViewById(R.id.uc1);
                l.setOrientation(LinearLayout.HORIZONTAL);
            }
        });

        // 垂直方向
        UC1_2=findViewById(R.id.button2);
        UC1_2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                LinearLayout l = findViewById(R.id.uc1);
                l.setOrientation(LinearLayout.VERTICAL);
            }
        });

        // 左靠方向
        UC1_3=findViewById(R.id.button3);
        UC1_3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                LinearLayout l = findViewById(R.id.uc1);
                l.setGravity(Gravity.LEFT);
            }
        });


        Button button4 = (Button) findViewById(R.id.button4);
        button4.setOnClickListener(new View.OnClickListener(){
            @Override
            public  void onClick(View v){
                Intent m = new Intent(UC1.this,MainActivity.class);
                startActivity(m);
            }
        });
    }
}
